﻿using System;
using System.Data;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.SqlClient;

/// <summary>
/// Summary description for clsAcount
/// </summary>
public class clsAcount
{
    string _user ="";
    string _pass = "";
	public clsAcount(string user, string pass)
	{
        _user = user;
        _pass = pass;
	}
    //0:Sai; 1: User 2: Admin
    public int checkAcount()
    {
        _user = _user.Replace("'", "");
        _user = _user.Replace("(", "");
        _user = _user.Replace(")", "");
        _user = _user.Replace("or", "");


        clsTableAction clsTable = new clsTableAction("acounts");
        string cri = string.Format(" username='{0}' and pass='{1}'", _user, _pass);
        SqlDataReader sqlDare = clsTable.exportDataReader("permission", cri);

        int n = 0;
        if (sqlDare.Read())
            n= Convert.ToInt32(sqlDare[0]);
        else
            n= 0;

        clsTable.free();
        return n;
    }
}
